<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_managers', function (Blueprint $table) {
            $table->id();
            $table->integer('company_category_id')->default(0)->comment('公司分类id');
            $table->string('company_name')->default('')->comment('公司名称');
            $table->string('customer_login_name')->default('')->comment('客户登录名称');
            $table->string('contact_title')->default('')->comment('1老板2运营');
            $table->string('contact_name')->default('')->comment('联系人名称');
            $table->string('contact_phone')->default('')->comment('联系人电话');
            $table->string('company_address')->default('')->comment('公司地址');
            $table->string('bill_settlement_group')->default('')->comment('账单结算群');
            $table->string('on_line_time')->default('')->comment('在线等待时间段');
            $table->integer('estimated_consultation_num')->default(0)->comment('预估咨询量');
            $table->integer('service_category_id')->default(0)->comment('服务类型');
            $table->decimal('source_price',10,1)->default(0)->comment('原始报价');
            $table->integer('department_one_id')->default(0)->comment('一级部门id');
            $table->integer('department_two_id')->default(0)->comment('二级部门id');
            $table->integer('department_three_id')->default(0)->comment('三级部门id');
            $table->integer('department_id')->default(0)->comment('最终分配的部门');
            $table->integer('system_user_id')->default(0)->comment('负责人id');
            $table->integer('system_user_name')->default(0)->comment('负责人名称');
            $table->tinyInteger('contract_source')->default(1)->comment('合同来源1线上2线下');
            $table->tinyInteger('contract_status')->default(1)->comment('合同状态1已回传2已寄出3未寄');
            $table->string('mark')->default('')->comment('备注');
            $table->integer('total_num')->default(0)->comment('店铺总数');
            $table->integer('sub_account_num')->default(0)->comment('子账号数量');
            $table->integer('customer_complaints_num')->default(0)->comment('客诉数量');

            $table->tinyInteger('status')->default(1)->comment('状态1正常2禁用');
            $table->tinyInteger('cooperation_status')->default(1)->comment('状态1正常2终止');
            $table->dateTime('breakup_time')->nullable()->comment('终止合作时间');
            $table->tinyInteger('advance_order')->default(0)->comment('预账单生成方式1按自然月2按非自然月');
            $table->timestamp('settle_date')->nullable()->comment('结算日期');
            $table->string('last_login_ip',32)->default('')->comment('客户登录手机号');
            $table->string('remember_token',128)->default('')->comment('登录token');
            $table->string('login_phone',128)->default('')->comment('登录手机号');
            $table->timestamp('last_login_time')->nullable()->comment('最后登录时间');
            $table->tinyInteger('is_bill_stopped')->default(0)->comment('是否已终止账单：默认0否，1是');
            $table->tinyInteger('is_has_commission')->default(0)->comment('是否有佣金：默认0否，1是');
            $table->integer('service_days')->default(0)->comment('服务天数');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `customer_managers` comment '客户管理'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_managers');
    }
};
